home *** CD-ROM | disk | FTP | other *** search
/ The World of Computer Software / The World of Computer Software.iso / em-xmkit.zip / EMM05_A.ASM < prev    next >
Assembly Source File  |  1989-11-29  |  7KB  |  123 lines

  1. ;-----------------------------------------------------------------------------;
  2. ;      MODULE NAME:   EMM05_A.ASM                                             ;
  3. ;                                                                             ;
  4. ;    FUNCTION NAME:   map_unmap_page                                          ;
  5. ;                                                                             ;
  6. ;      DESCRIPTION:   This function maps a logical page at a specific         ;
  7. ;                     physical page anywhere in the mappable regions of       ;
  8. ;                     system memory.    The lowest-valued physical page       ;
  9. ;                     numbers are associated with regions of memory outside   ;
  10. ;                     the conventional memory range.  Use the                 ;
  11. ;                     get_mappable_regions function to determine which        ;
  12. ;                     physical pages within a system are mappable, and to     ;
  13. ;                     determine which segment addresses correspond to which   ;
  14. ;                     specific physical page number.  The get_mappable_region ;
  15. ;                     function provides a cross reference between physical    ;
  16. ;                     page numbers and segment addresses.                     ;
  17. ;                                                                             ;
  18. ;                     This function can also unmap physical pages, making     ;
  19. ;                     them inaccessible for reading or writing.  You unmap a  ;
  20. ;                     physical page by setting its associated logical page to ;
  21. ;                     -1.  For example, you might unmap an entire set of      ;
  22. ;                     mapped pages before loading and executing a program.    ;
  23. ;                     Doing so ensures that if the loaded program accesses    ;
  24. ;                     expanded memory, it won't access the pages your program ;
  25. ;                     has mapped.  However, you must save the mapping context ;
  26. ;                     before you unmap the physical pages.  Saving the        ;
  27. ;                     context enables you to restore it later so you can      ;
  28. ;                     access the memory you mapped there.  To save the        ;
  29. ;                     mapping context, use the save_context, get_context, and ;
  30. ;                     get_partial_context functions.  To restore the mapping  ;
  31. ;                     context, use the restore_context, set_context,          ;
  32. ;                     get_set_context, and set_partial_context_functions.     ;
  33. ;                                                                             ;
  34. ;                     The handle determines what type of pages are being      ;
  35. ;                     mapped.  Logical pages allocated by the alloc_pages and ;
  36. ;                     alloc_std_pages functions are referred to as pages and  ;
  37. ;                     are 16K bytes long.  Logical pages allocated by the     ;
  38. ;                     alloc_raw_pages function are referred to as raw pages   ;
  39. ;                     and might not be the same size as logical pages.        ;
  40. ;                                                                             ;
  41. ;           PASSED:   phys_page:                                              ;
  42. ;                        is the number of the physical page into which the    ;
  43. ;                        logical page number is to be mapped.  Physical pages ;
  44. ;                        are numbered relative to zero.                       ;
  45. ;                                                                             ;
  46. ;                     log_page:                                               ;
  47. ;                        is the number of the logical page to be mapped at    ;
  48. ;                        the physical page within the page frame.  Logical    ;
  49. ;                        pages are numbered relative to zero.  The logical    ;
  50. ;                        page must be in the range zero through (number of    ;
  51. ;                        pages allocated to the EMM handle - 1).  However,    ;
  52. ;                        if log_page is -1, the physical page specified by    ;
  53. ;                        phys_page will be unmapped (be made inaccessible     ;
  54. ;                        for reading or writing).                             ;
  55. ;                                                                             ;
  56. ;                     handle:                                                 ;
  57. ;                        is the EMM handle returned by the alloc_pages,       ;
  58. ;                        alloc_std_pages, or alloc_raw_pages functions.       ;
  59. ;                                                                             ;
  60. ;         RETURNED:   status:                                                 ;
  61. ;                        is the status EMM returns from the call.  All other  ;
  62. ;                        returned results are valid only if the status        ;
  63. ;                        returned is zero.  Otherwise they are undefined.     ;
  64. ;                                                                             ;
  65. ; C USE CONVENTION:   unsigned int status;                                    ;
  66. ;                     unsigned int phys_page;                                 ;
  67. ;                     unsigned int log_page;                                  ;
  68. ;                     unsigned int handle;                                    ;
  69. ;                                                                             ;
  70. ;                     status = map_unmap_page (phys_page,                     ;
  71. ;                                              log_page,                      ;
  72. ;                                              handle);                       ;
  73. ;-----------------------------------------------------------------------------;
  74. .XLIST
  75. PAGE    60,132
  76.  
  77. IFDEF SMALL
  78.    .MODEL SMALL, C
  79. ENDIF
  80. IFDEF MEDIUM
  81.    .MODEL MEDIUM, C
  82. ENDIF
  83. IFDEF LARGE
  84.    .MODEL LARGE, C
  85. ENDIF
  86. IFDEF COMPACT
  87.    .MODEL COMPACT, C
  88. ENDIF
  89. IFDEF HUGE
  90.    .MODEL HUGE, C
  91. ENDIF
  92.  
  93. INCLUDE emmlib.equ
  94. INCLUDE emmlib.str
  95. INCLUDE emmlib.mac
  96. .LIST
  97. .CODE
  98.  
  99. map_unmap_page        PROC                                                  \
  100.             phys_page:BYTE,                                       \
  101.             log_page:WORD,                                        \
  102.             handle:WORD
  103.  
  104.     ;---------------------------------------------------------------------;
  105.     ;   do;                                                               ;
  106.     ;   .   map a logical page owned by a handle at a physical page;      ;
  107.     ;---------------------------------------------------------------------;
  108.     MOVE        AH, map_page_fcn
  109.     MOVE        AL, phys_page
  110.     MOVE        BX, log_page
  111.     MOVE        DX, handle
  112.     INT         EMM_int
  113.  
  114.     ;---------------------------------------------------------------------;
  115.     ;   .   return (EMM status);                                          ;
  116.     ;   end;                                                              ;
  117.     ;---------------------------------------------------------------------;
  118.     RET_EMM_STAT    AH
  119.  
  120. map_unmap_page        ENDP
  121.  
  122. END
  123.